Add MSBuild csproj recipes + .sln .njsproj filter#7518
Open
Conversation
C# (csproj transformations, registered with CsprojRecipeActivator): - AddFrameworkReference: adds <FrameworkReference> when removing meta-packages (e.g., Microsoft.AspNetCore.App after dropping Microsoft.AspNetCore.All) - RemoveDotNetCliToolReference: removes <DotNetCliToolReference> items (the netcoreapp2.x per-project CLI tool mechanism, gone in net3+) - RemoveMSBuildProperty: removes named <PropertyGroup> properties (e.g., RuntimeFrameworkVersion, PackageTargetFallback) Java (sln cleanup): - org.openrewrite.csharp.sln.RemoveNjsprojFromSolution: removes Project entries with .njsproj (Node.js Tools) extension from .sln/.slnx, plus associated ProjectConfigurationPlatforms / NestedProjects entries. dotnet build can't process .njsproj because the SDK doesn't ship Microsoft.NodejsTools.targets. Note: the Java sln recipe is in the rewrite-csharp jar but mod CLI's marketplace currently doesn't expose Java recipes from rewrite-csharp via the NuGet recipe bundle path — the recipe is registered in recipes.csv and discoverable on classpath but not yet usable from a NuGet recipe package. Foundation is in place for follow-up.
…h set Previously, any test SourceSpec with a non-null SourcePath was routed through the Java RPC parser, which doesn't ship a C# parser — so multi-project tests that needed C# files at specific paths (e.g., to test path-based per-project recipe scoping) couldn't be expressed. Now: .cs source paths route through the local CSharpParser with the test's sourcePath; only non-.cs/non-.csproj source paths go to Java RPC. Local C# parsing already supports a custom sourcePath via CSharpParser.Parse(..., sourcePath: ...) — this just plumbs the test's spec.SourcePath through. Enables tests like AddNuGetPackageReferenceIfTypeUsedTest where the recipe needs to map .cs files to their containing csproj by directory prefix.
The recipe was registered in the C# environment but is not yet usable from a NuGet recipe package, and the corresponding recipes.csv entry was reverted — leaving recipeCsvValidateCompleteness to fail in CI. Drop the recipe for now; it can be reintroduced when the marketplace path for Java recipes in rewrite-csharp is in place.
Previously RPC_TEST_SERVER_CLASSPATH was required, and a stale value inherited from a different rewrite checkout would silently point tests at outdated Java JARs — surfacing as cryptic "recipe didn't fire" failures. Now resolve the classpath file from the loaded SDK assembly location (handling both in-repo runs and consuming projects that source- link via `external/openrewrite/rewrite`), and prefer the SDK-relative file when the env var is older or missing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CsprojRecipeActivator:AddFrameworkReference(e.g., forMicrosoft.AspNetCore.Appafter dropping the.Allmeta-package),RemoveDotNetCliToolReference(gone in net3+), andRemoveMSBuildProperty(e.g.,RuntimeFrameworkVersion,PackageTargetFallback).org.openrewrite.csharp.sln.RemoveNjsprojFromSolutionthat strips.njsprojProject entries and theirProjectConfigurationPlatforms/NestedProjectsentries from.sln/.slnx(since the .NET SDK doesn't shipMicrosoft.NodejsTools.targets).RewriteTestso test specs with aSourcePathfor.csfiles route through the localCSharpParserinstead of the Java RPC parser, enabling tests that need C# files at specific paths.Test plan
./gradlew :rewrite-csharp:testdotnet testfor therewrite-csharpC# solution (AddFrameworkReferenceTests,RemoveDotNetCliToolReferenceTests,RemoveMSBuildPropertyTests)